λ git rebase -i
Interactiveにgit rebaseする
実行
$ git rebase -i <commit>
e.g. $ git rebase -i @~3
e.g. $ git rebase -i xxxxxx~1
実行するとeditorが立ち上がるので、そこでcommitを編集する
下に行くほど新しいcommit
コマンドの種類
pick (rebase)
何もしない
edit (rebase)
commitを一時停止して変更を加えることができる
squash (rebase)
commitをまとめる
fixup (rebase)
fixup
commitをまとめる
commit messageは残さない
ref 2つ以上前のcommitにamendする
reword (rebase)
commit messageの編集
exec
drop (rebase)
過去のcommitを削除する
label
reset
merge
git rebase -iを実行したときに開かれるeditorの下部に書かれてるmrsekut.icon
https://tkengo.github.io/blog/2013/05/16/git-rebase-reference/
--autosquash
2つ以上前のcommitにamendするに書いた
--autostash
rebaseする際に自動的にgit stashし、rebase作業が終わればpopしてくれる
ユースケース
過去の1つのcommitを取り消す
過去の複数のcommitを1つのcommitにまとめる
2つ以上過去のcommit messageを修正する
2つ以上前のcommitにamendする
過去のcommitを分割する
rebase -i @~10とかは、
6が目的なのに、無駄に10とかすると、10個分全てが新しいhashになるので注意mrsekut.icon
gitのコミットの歴史を改変する(git rebase) 1 / 2 · けんごのお屋敷
わかりやすいmrsekut.icon*2
https://tkengo.github.io/blog/2013/06/08/git-rebase-reference2/
続き